/*******************************************
 * Copyright 2007 Aphrodite Framework for javaME .
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Public License v2.0
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 * Email : owner@aphroditeme.dev.java.net
 * Contributors:
 *     Kent Elton - initial API and implementation
 *******************************************/

package com.aphrodite.io;

import java.io.IOException;

/**
 * Allows persistence in j2me
 * <p>
 * Implementing classes should use the following logic to implement the
 * <i>save</i> and <i>load</i> methods<br/> Consider a simple class <br/> class
 * Serial implements Persistent{<br/> int age; <br/> String name;<br/> int
 * height;<br/> <b>Implementing Save</b><br/> .. <br/> ..<br/>
 * ByteArrayOutputStream bout = new ByteArrayOutputStream();<br/>
 * DataOutputStream dout = new DataOutputStream( bout );<br/>
 * dout.writeInt(age);<br/> dout.writeUTF(name);<br/>
 * dout.writeInt(height);<br/> dout.flush();<br/> return
 * bout.toByteArray();<br/>
 * 
 * <b>Implementing Load</b><br/> ByteArrayInputStream bin = new
 * ByteArrayInputStream( data );<br/> DataInputStream din = new DataInputStream(
 * bin );<br/> age = din.readInt(); <br/> name = din.readUTF(); <br/> height =
 * din.readInt();<br/>
 * </p>
 * 
 * @author kentelt
 * 
 */
public interface Persistent {
	void load(byte[] data) throws IOException;

	byte[] save() throws IOException;

}
